#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const double INF=0x3f3f3f3f3f3f3f3f;
const double esp=1e-8;
ll T,n;
ll a[10100],b[10010],c[10010];
double f(double x){
    double maxn=a[0]*x*x+b[0]*x+c[0];;
    for(ll i=1;i<n;i++){
        double number=a[i]*x*x+b[i]*x+c[i];
        if(number-maxn>esp){
            maxn=number;
        }
    }
    return maxn;
}

int main()
{
    IOS;
    cin>>T;
    while(T--){
        cin>>n;
        for(ll i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
        }
        double l=0,r=1000.0;
        double maxn1,maxn2;
        ll cnt=100;
        while(cnt--){
            // cout<<"L="<<l<<endl;
            // cout<<"R="<<r<<endl;
            double x1=(r-l)/3+l;
            double x2=r-(r-l)/3;
            // cout<<"x1="<<x1<<endl;
            // cout<<"x2="<<x2<<endl;
            // double maxnl=f(l);
            // double maxnr=f(r);
            maxn1=f(x1);
            maxn2=f(x2);
            // cout<<"maxn1="<<maxn1<<endl;
            // cout<<"maxn2="<<maxn2<<endl;
            if(maxn1-maxn2>esp){
                l=x1;
                // cout<<"right"<<endl;
            }
            else{
                r=x2;
                // cout<<"left"<<endl;
            }
        }
        double ans=f(l);
        printf("%.4f\n",ans);
    }    
    getchar();
    getchar();
    return 0;
}
